<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Gerenciamento de categoria</title>
    </h:head>
    <h:body>

        <p:layout fullPage="true">

            <p:layoutUnit position="south" size="60" style="text-align: center">
                <h:form>
                    <p:button outcome="venda" value="Vender"/>
                    <p:button outcome="produtos" value="Cadastrar item"/>
                </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="north">
                <h:form>
                    <p:growl id="messages" showDetail="true" />
                    <h:inputHidden value="#{categoriaBean.categoria.id}"/>
                    <h:panelGrid columns="3">
                        <h:outputLabel value="Nome:" for="nome"/>
                        <p:inputText value="#{categoriaBean.categoria.nome}" id="nome"/>
                        <p:commandButton value="Salvar" actionListener="#{categoriaBean.salvar()}" ajax="false"/>                        
                    </h:panelGrid>
                </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="center">
                <h:form>
                    <p:dataTable var="categoria" value="#{categoriaBean.listar}">
                        <p:column headerText="Id">
                            <h:outputText value="#{categoria.id}" />
                        </p:column>

                        <p:column headerText="Nome">
                            <h:outputText value="#{categoria.nome}" />
                        </p:column>

                        <p:column headerText="Ações" style="text-align: center;">
                            <h:commandLink action="#{categoriaBean.excluir(categoria)}">
                                <h:graphicImage library="img" name="glyphicons_016_bin.png" style="margin:0 10px;"/>
                            </h:commandLink>

                            <h:commandLink action="#{categoriaBean.setCategoria(categoria)}">
                                <h:graphicImage library="img" name="glyphicons_030_pencil.png"/>
                            </h:commandLink>
                        </p:column>

                    </p:dataTable>
                </h:form>
            </p:layoutUnit>

        </p:layout>

    </h:body>
</html>